<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>
<%@page import="java.net.*"%>
<%
	String name = request.getParameter("name");
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	
	String temp = "";
	String _db = user.getDbType();
	Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	List<Map<String, String>> list = null;
	String tbe_employment_forms = "";//用工形式
	String tbe_nation = "";//民族
	String tbe_marital_status = "";//婚姻状态
	String tbe_status = "";//员工状态
	String tbe_ba_status = "";//生育能力状态
	String tbe_birth_control_measures = "";//节育措施
	String tbe_es_reason="";//重点理由
	list = dicMap.get("101");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_employment_forms += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("5");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_nation += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("102");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("103");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_ba_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("104");
	if(null != list && list.size() > 0){
       String first_value="";
		for(Map<String, String> map: list){
		   if("104-8"==map.get("tmgd_id")){
		     first_value= "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		        break;
		     }
			tbe_birth_control_measures += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
		tbe_birth_control_measures=first_value+tbe_birth_control_measures;
	}
	list = null;
	list = dicMap.get("107");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_es_reason += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>人员婚姻</title>
		<base href="<%=basePath%>" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>

		<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.employee.EmpMaritalAction";
_jsonObj.methodname = "queryPage";
_jsonObj.logicdata = "[{\"types\":\"init\"}]";

var _jsonObj0 = {
	"classname":"com.wxtf.platform.main.employee.EmployeeAction",
	"methodname":"listAll",
	"logicdata":"[{\"tbe_name\":\"\",\"tbe_idcard\":\"\",\"tbe_sex\":\"\"}]"
};
var win1;//高级检索弹出框
var win2;//婚姻变动详细窗口
var win4;//配偶信息选择
var manager;//人员表格
var arraySerarchList = new Array();//高级搜索条件数组

$(function(){
	manager = $("#emp_grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,
		columns: [
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构名称', name: 'org_name', width:100, align: 'left' },
			{ display: '姓名', name: 'tbe_name', width: 100, align: 'left',render: function(record, index, value, oth){
					return " <a href='javascript:openwin(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}  },
			{ display: '性别', name: 'tbe_sex',width:60, align: 'center'},
			{ display: '年龄', name: 'tbe_age', width: 1,hide: true },
			{ display: '出生日期', name: 'tbe_birthday', width: 100, align: 'left' },
			{ display: '机构名称', name: 'reserve1', hide: true,width:1, align:'left' },
			{ display: '身份证号', name: 'tbe_idcard', width: 180, align: 'left' },
			{ display: '职工证号', name: 'tbe_work_permit', width: 1, hide:true },
			{ display: '用工形式', name: 'tbe_employment_forms', width:  1, hide:true },
			{ display: '曾用名', name: 'tbe_former_name', hide: true,width:1, align: 'left' },
			{ display: '拼音码', name: 'tbe_spell_code', hide: true,width:1, align: 'left' },
			{ display: '籍贯', name: 'tbe_native_palce', width: 1, hide:true },
			{ display: '民族', name: 'tbe_nation', width:  1, hide:true },
			{ display: '出生地', name: 'tbe_birthplace', width:  1, hide:true },
			{ display: '入厂时间', name: 'tbe_join_time', width:  1, hide:true },
			{ display: '工龄', name: 'tbe_seniority', width:  1, hide:true },
			{ display: '手机', name: 'tbe_mobile', width: 1,hide:true },
			{ display: '家庭电话', name: 'tbe_family_phone', width:  1,hide:true },
			{ display: '家庭住址', name: 'tbe_address', width:  1,hide:true },
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 80, align: 'center',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%}}%>
					return value;
				}
			},
			{ display: '婚姻状况', name: 'tbe_marital_condition', width: 1, hide:true },
			{ display: '结婚时间', name: 'tbe_married_time', width:120, align: 'left' },
			{ display: '结婚证号', name: 'tbe_marriage_certificate', width: 100, align: 'left' },
			{ display: '政治面貌', name: 'tbe_political_status', width:  1, hide:true },
			{ display: '学历', name: 'tbe_qualification', width:  1, hide:true },
			{ display: '毕业学校', name: 'tbe_graduate_college', width:  1, hide:true },
			{ display: '所学专业', name: 'tbe_major', width:  1, hide:true },
			{ display: '工作时间', name: 'tbe_work_area', width:  1, hide:true },
			{ display: '职务', name: 'tbe_position', width:  1, hide:true },
			{ display: '是否允许再生育', name: 'tbe_is_again_birth', width:1, hide:true },
			{ display: '是否不孕症', name: 'tbe_is_barrenness', width:1, hide:true},
			{ display: '是否晚婚', name: 'tbe_is_late_marriage', width:  1, hide:true },
			{ display: '本季结婚', name: 'emp_reserve5', width:  1, hide:true },
			{ display: '是否晚育', name: 'tbe_is_late_birth', width:  1, hide:true },
			{ display: '员工状态', name: 'tbe_status', width:  1, hide:true },
			{ display: '生育能力状态', name: 'tbe_ba_status', width:  1, hide:true },
			{ display: '节育措施', name: 'tbe_birth_control_measures', width:  1, hide:true },
			{ display: '设为重点时间', name: 'tbe_es_time', width:  1, hide:true },
			{ display: '是否重点服务对象', name: 'tbe_is_es', width:  1, hide:true },
			{ display: '重点理由', name: 'tbe_es_reason', width:  1, hide:true },
			{ display: '子女情况', name: 'tbe_children_status', width:  1, hide:true },
			{ display: '排序号', name: 'tbe_order', width:  1, hide:true },
			{ display: '备注', name: 'tbe_memo', width:  1, hide:true },
			{ display: '家庭子女数', name: 'tbfi_children_num', width: 80, align: 'left' },
			{ display: '男孩数', name: 'tbfi_children_mnum', width: 80, align: 'left' },
			{ display: '女孩数', name: 'tbfi_children_fnum', width: 80, align: 'left' },
			{ display: '家庭是否有效', name: 'tbfi_valid', width: 1, hide:true, align: 'left',
				render: function(record, index, value, oth){ return value == '1' ? '是' : '否'; }
			},
			{ display: 'reserve2', name: 'reserve2', width:  1, hide:true },
			{ display: 'reserve3', name: 'reserve3', width:  1, hide:true },
			{ display: 'reserve4', name: 'reserve4', width:  1, hide:true },
			{ display: 'reserve5', name: 'reserve5', width:  1, hide:true },
			{ display: '录入人', name: 'create_by', width:  1, hide:true },
			{ display: '录入时间', name: 'create_time', width:  1, hide:true },
			{ display: '最后修改人', name: 'last_modify_by', width:  1, hide:true },
			{ display: '最后修改时间', name: 'last_modify_time', width: 1, hide:true },
			{ display: '编辑', name:'edit',width:60,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='openwin(" + JSON.stringify(record) + ")'></img>";
				}
			},
			{ display: '转到办证', name:'edit',width:80,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/002.gif' onclick='dispatchCredentials(\"" + record.tbe_name + "\")'></img>";
				}
			}
		],
		onCheckRow: function(checked, rowdata, rowindex) {
		    for (var rowid in this.records)
		        this.unselect(rowid); 
		    this.select(rowindex);
		}
	});
	$("#tbe_married_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#tbfi_spouse_birthday").ligerDateEditor({ format: "yyyy-MM-dd", width:182});

	<%
		if(name != null){
	%>
		$('#ser1').val('<%=URLDecoder.decode(name, "UTF-8")%>');
		serch1();
	<%
	}
	%>

});

/*
 * 跳转到办证登记
 */
function dispatchCredentials(name){
	var tabId = '_tab_dd69b2976cff498bb8775dd7f92af9cb';
	parent.removeTab(tabId);
	parent.f_addTab(tabId, '办证登记', 'jsp/sygl/credentials_record.jsp?name=' + encodeURI(encodeURI(name)));
}

/*
*显示婚姻变动详细信息
*/
function openwin(row){
	document.getElementById('emp_mari_form').reset();
	
	$("#tbe_id").val(row.tbe_id);
	$("#tbe_name").val(row.tbe_name);
	$("#tbe_sex").val(row.tbe_sex);
	$("#tbe_status").val(row.tbe_status);
	$("[name='checkbox1']").attr("checked", row.tbfi_spouse_is_join == 1);
	$('#tbfi_spouse_is_join').val(row.tbfi_spouse_is_join);
	document.getElementById('empBtn').disabled = (row.tbfi_spouse_is_join != 1);
	
	<%
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
	%>
	if(row.tbe_marital_status == '<%=map.get("tmgd_id")%>'){
	$("#tbe_marital_status_").val('<%= map.get("tmgd_name") %>'); 
	}
	<%
		}
	}
	%>
	$("#tbe_spouse_id").val(row.tbe_spouse_id); 
	$("#tbfi_spouse_name").val(row.tbfi_spouse_name); 
	$("#tbfi_spouse_sex").val(row.tbfi_spouse_sex); 
	$("#tbfi_spouse_age").val(row.tbfi_spouse_age); 
	$("#tbfi_spouse_birthday").val(row.tbfi_spouse_birthday); 
	$("#tbfi_spouse_idcard").val(row.tbfi_spouse_idcard); 
	$("#tbfi_spouse_idcard_u").val(row.tbfi_spouse_idcard);//后台该状态使用 
	$("#tbfi_spouse_department").val(row.tbfi_spouse_department); 
	$("#tbfi_spouse_position").val(row.tbfi_spouse_position); 
	$("#tbfi_phone").val(row.tbfi_phone); 
	$("#tbfi_mobile").val(row.tbfi_mobile); 
	$("#tbfi_valid").val(row.tbfi_valid); 
	$("#tbfi_address").val(row.tbfi_address);
	$("#tbfi_memo").val(row.tbfi_memo);
	$("#tbfi_peo_num").val(row.tbfi_peo_num); 
	$("#tbfi_children_num").val(row.tbfi_children_num); 
	$("#tbfi_children_mnum").val(row.tbfi_children_mnum);
	$("#tbfi_children_fnum").val(row.tbfi_children_fnum);
	$('#tbe_age').val(row.tbe_age);
	$('#tbe_birthday').val(row.tbe_birthday);
	$('#tbe_idcard').val(row.tbe_idcard);
	$('#tbe_position').val(row.tbe_position);
	$('#reserve1').val(row.reserve1);//员工的单位
	$('#tbe_marital_status').val(row.tbe_marital_status);
	$('#tbe_married_time').val(row.tbe_married_time);
	$('#tbe_marriage_certificate').val(row.tbe_marriage_certificate);
	$("input[name=tbe_is_late_marriage][value="+row.tbe_is_late_marriage+"]").attr("checked",true);
	$("input[name=emp_reserve5][value="+row.emp_reserve5+"]").attr("checked",true);
    
	if(win2==null){
	    win2=initWindowByDiv('emp_mari', '人员婚姻变动', 880, 470 ,save, closeWin);
	}else{
		win2.show();
	}
	checkEmp();//检查字段可否输入
}

//婚姻变更的保存
function save(){
	$("#tbe_marital_status_text").val($("#tbe_marital_status").find("option:selected").text());
	var mstatus = $('#tbe_marital_status').val();//婚姻状态
	var tbfi_spouse_name = $('#tbfi_spouse_name').val().trim();
	var tbfi_spouse_birthday = $('#tbfi_spouse_birthday').val().trim();
	var tbfi_spouse_idcard = $('#tbfi_spouse_idcard').val().trim();
	var tbe_married_time = $('#tbe_married_time').val();//结婚时间
	var tbe_marriage_certificate = $('#tbe_marriage_certificate').val().trim();
	var tbfi_spouse_department = $('#tbfi_spouse_department').val().trim();
	var tbe_spell_code = $('#tbe_spell_code').val().trim();
	var tbe_qualification = $('#tbe_qualification').val().trim();
	var tbfi_phone = $('#tbfi_phone').val().trim();
	var tbfi_address = $('#tbfi_address').val().trim();
	var tbfi_memo = $('#tbfi_memo').val().trim();

	if(fucCheckLength(tbe_marriage_certificate) > 32){
		warningTip('结婚证号：不能超过32字符');
		return;
	}
	if(!checkIsString(tbe_marriage_certificate)){
		warningTip("结婚证号：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbfi_spouse_name) > 32){
		warningTip('配偶姓名：不能超过32字符');
		return;
	}
	if(!checkIsString(tbfi_spouse_name)){
		warningTip("配偶姓名：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbfi_spouse_idcard) > 32){
		warningTip('身份证号：不能超过32字符');
		return;
	}
	if(!checkIsString(tbfi_spouse_idcard)){
		warningTip("身份证号：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbfi_spouse_department) > 64){
		warningTip('配偶单位：不能超过64字符');
		return;
	}
	if(!checkIsString(tbfi_spouse_department)){
		warningTip("配偶单位：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbe_spell_code) > 32){
		warningTip('职务：不能超过32字符');
		return;
	}
	if(!checkIsString(tbe_spell_code)){
		warningTip("职务：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbe_qualification) > 32){
		warningTip('文化程度：不能超过32字符');
		return;
	}
	if(!checkIsString(tbe_qualification)){
		warningTip("文化程度：必须为字母、数字、下划线、中文组成");
		return;
	}
	/*
	if(fucCheckLength(tbfi_phone) > 32){
		warningTip('家庭电话：不能超过32字符');
		return;
	}
	if(!checkIsTelephone(tbfi_phone)){
		warningTip("家庭电话：格式应为12345678、0431-12345678、0431-12345678-12345");
		return;
	}
	if(fucCheckLength(tbfi_address) > 128){
		warningTip('家庭地址：不能超过128字符');
		return;
	}
	if(!checkIsString(tbfi_address)){
		warningTip("家庭地址：必须为字母、数字、下划线、中文组成");
		return;
	}
	*/
	if(fucCheckLength(tbfi_memo) > 512){
		warningTip('备注：不能超过512字符');
		return;
	}
	if(!checkIsString(tbfi_memo)){
		warningTip("备注：必须为字母、数字、下划线、中文组成");
		return;
	}
	var mnum = $('#tbfi_children_mnum').val().trim();//男孩数
	var fnum = $('#tbfi_children_fnum').val().trim();//女孩数
	
	if(!isNum(mnum, '+')){
		warningTip("男孩数：请输入正整数");
		return;
	}
	if(!isNum(fnum, '+')){
		warningTip("女孩数：请输入正整数");
		return;
	}

	//未婚时填写了配偶信息
	if(mstatus == '8A90F0D0176C4961B322BEB26703A320' && ('' != tbfi_spouse_name || '' != tbfi_spouse_birthday || '' != tbfi_spouse_idcard)){
		warningTip('填写了配偶信息，请将婚姻状态置为已婚');
		return;
	}

	//已婚/再婚
	if('8A90F0D0176C4961B322BEB26703A321' == mstatus || mstatus == 'EC88549D43494FFE8E277192921D7617'){
		if(tbe_married_time == ''){
			warningTip('结婚时间：不能为空');
			return;
		}
		if(tbfi_spouse_birthday == ''){
			warningTip('配偶出生日期：不能为空');
			return;
		}
		/*
		if(tbfi_spouse_name == ''){
			warningTip('配偶姓名：不能为空');
			return;
		}
		if(tbfi_spouse_idcard == ''){
			warningTip('配偶身份号：不能为空');
			return;
		}
		*/
	}

	var emp_reserve5 = $(":radio[name='emp_reserve5']:checked").val();//本季新婚
	var tbe_is_late_marriage = $(":radio[name='tbe_is_late_marriage']:checked").val();//新婚且晚婚
	if(tbe_is_late_marriage == '1'){
		if(emp_reserve5 != '1'){
			warningTip('本季新结婚的：新结婚且晚婚选择“是”，则本季新结婚的必须选“是”');
			return;
		}
	}
	
	_jsonObj.methodname = "update_mar";
	_jsonObj.logicdata = getForm("emp_mari_form");
	callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
}

function valiMarital(ele){
	var newStatus = ele.value;
	var row = manager.getSelected();
	var oldStatus = row.tbe_marital_status;
	if(oldStatus != '8A90F0D0176C4961B322BEB26703A320' && newStatus == '8A90F0D0176C4961B322BEB26703A320'){
		warningTip('婚姻状态：不能修改为未婚');
		ele.value = oldStatus;
	}
}

/*
 * 是否是一汽职工
 */
function checkEmp(flag){
	var btn = document.getElementById('empBtn');
	var ele = document.getElementById('checkbox1');
	if(ele.checked){//是
		btn.disabled = false;
		document.getElementById('tbfi_spouse_is_join').value = 1;
		$('#tbfi_spouse_name').attr("readonly", "readonly");
		$('#tbfi_spouse_sex').attr("readonly", "readonly");
		$('#tbfi_spouse_birthday').attr("readonly", "readonly");
		$('#tbfi_spouse_idcard').attr("readonly", "readonly");
		$('#tbfi_spouse_department').attr("readonly", "readonly");
	} else{//否
		document.getElementById('tbfi_spouse_is_join').value = 0;
		btn.disabled = true;
		$('#tbfi_spouse_name').removeAttr("readonly");
		$('#tbfi_spouse_birthday').removeAttr("readonly");
		$('#tbfi_spouse_idcard').removeAttr("readonly");
		$('#tbfi_spouse_department').removeAttr("readonly");
	}
	if(flag == 1){
		$('#tbe_spouse_id').val("");
		$('#tbfi_spouse_name').val("");
		$('#tbfi_spouse_sex').val($("#tbe_sex").val() == '男'?'女':'男');
		$('#tbfi_spouse_birthday').val("");
		$('#tbfi_spouse_idcard').val("");
		$('#tbfi_spouse_department').val("");
		$('#tbe_spell_code').val("");
		$('#tbe_qualification').val("");
		$('#tbfi_spouse_position').val("");
	}
}
/*
 * 选人弹出框
 */
function openEmp(){
	var tbe_sex = $('#tbe_sex').val().trim();
	_jsonObj0.logicdata = '[{\"tbe_name\":\"\",\"tbe_idcard\":\"\",\"tbe_sex\":\"'+tbe_sex+'\"}]';
	
	if(win4==null){
		win4 = initWindowByDiv('grid0-win', '选择人员', 520, 360, function(item, dialog){
			var row = grid0.getSelecteds();
			if(row.length != 1){
				warningTip('请选择一个用户');
				return;
			}
			if(row[0].tbe_id == $('#tbe_id').val()){
				warningTip('不能选择同一个人');
				return;
			}
			
			$('#tbe_spouse_id').val(row[0].tbe_id);
			$('#tbfi_spouse_name').val(row[0].tbe_name);
			$('#tbfi_spouse_sex').val(row[0].tbe_sex);
			$('#tbfi_spouse_age').val(row[0].tbe_age);
			$('#tbfi_spouse_birthday').val(row[0].tbe_birthday);
			$('#tbfi_spouse_idcard').val(row[0].tbe_idcard);
			$('#tbfi_spouse_department').val(row[0].reserve1);
			$('#tbfi_spouse_position').val(row[0].tbe_position);
			$('#tbe_spell_code').val(row[0].tbe_spell_code);
			$('#tbe_qualification').val(row[0].tbe_qualification);
			
			win4.hide();
		}, closeWin);
		
		grid0 = $("#grid0-div").ligerGrid({
			url:_url, parms:_jsonObj0, width: 500, height: 250,
			usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,
			columns: [
				{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
				{ display: '身份证号', name: 'tbe_idcard', width: 200, align: 'left' },
				{ display: '姓名', name: 'tbe_name', width: 150, align: 'left' },
				{ display: '性别', name: 'tbe_sex', width: 60, align: 'left' },
				{ display: '年龄', name: 'tbe_age', width:1,hide: true },
				{ display: '出生日期', name: 'tbe_birthday', width: 1,hide: true },
				{ display: 'org_id', name: 'org_id', width:1,hide: true },
				{ display: '机构名称', name: 'reserve1', width:1,hide: true },
				{ display: '职务', name: 'tbe_position', width:1,hide: true }
			],
			onCheckRow: function(checked, rowdata, rowindex) {
			    for (var rowid in this.records)
			        this.unselect(rowid); 
			    this.select(rowindex);
			}
		});
	} else {
		win4.show();
		grid0.loadData();
	}
}

/*
 * 选人弹出框-条件查询
 */
function serch3(){
	var tbe_name = $('#ser-name').val().trim();
	var ser_no = $('#ser-no').val().trim();
	var tbe_sex = $('#tbe_sex').val().trim();

	_jsonObj0.logicdata = '[{\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"' + ser_no + '\",\"tbe_sex\":\"'+tbe_sex+'\"}]';
	grid0.loadData();
}

/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#org2').val();
	var tbe_name = $('#ser1').val();
	var tbe_idcard = $('#ser4').val();
	var ser5 = $('#ser5').val();
	var ser6 = $('#ser6').val();
	var ser7 = $('#ser7').val();
	var ser8 = $('#ser8').val();
	
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_marital_status\":\"' + ser5
			+ '\",\"tbfi_spouse_is_join\":\"' + ser6 + '\",\"tbfi_children_num\":\"' + ser7
			+ '\",\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"' + tbe_idcard + '\",\"types\":\"serch1\"}]';
	manager.loadData();
}

/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	serch1();
	if(data.result || data.result == 'true'){
		succMsgTip(data.resultrecord);
	}else{
		warningTip(data.resultrecord);
	}
	if(win2 && data.result){
		win2.hide();
	}
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}

/*
 * 计算子女数
 */
function sumChild(){
	var mnum = $('#tbfi_children_mnum').val().trim();//男孩数
	var fnum = $('#tbfi_children_fnum').val().trim();//女孩数
	
	if(mnum == ''){
		$('#tbfi_children_mnum').val(0);
		mnum = 0;
	}
	if(fnum == ''){
		$('#tbfi_children_fnum').val(0);
		fnum = 0;
	}
	$('#tbfi_children_num').val(parseInt(mnum) + parseInt(fnum));
}

/*
 * 高级查询
 */
function serch2(){
	if(win1 == null){
		win1 = initWindowByDiv('tallSearch','高级查询', 670, 454, function(){
			var tableName = "";
        	var objArrayOne = $("[name=luojiOne]");
        	var objArrayTwo = $("[name=luojiTwo]");
        	var arrayColsName = $("[name=colsName]");
        	var arrayColsValue = $("[name=colsValue]");
        	
        	var tempSearch = "";
        	for(var i=0; i<arrayColsName.length; i++){
        		var conditionValue = objArrayOne[i+1].value;
        		if(conditionValue == "like"){
		        	arraySerarchList.push(" " + objArrayTwo[i+1].value+" "+tableName+arrayColsName[i].value+" "+objArrayOne[i+1].value+" '%"+arrayColsValue[i].value+"%' ");
        		}else if(conditionValue == "in"){
        			var strArr = arrayColsValue[i].value.split(",");
        			var tempStr = "";
        			for(var j=0; j<strArr.length; j++){
        				tempStr +="'"+strArr[j]+"',";
        			}
		        	arraySerarchList.push(" " + objArrayTwo[i+1].value+" "+tableName+arrayColsName[i].value+" "+objArrayOne[i+1].value+" ("+tempStr.substring(0,tempStr.length-1)+") ");
        		}else if(conditionValue == "between"){
        			var strArr = arrayColsValue[i].value.split(",");
		        	arraySerarchList.push(" " + objArrayTwo[i+1].value+" "+tableName+arrayColsName[i].value+" "+objArrayOne[i+1].value+" '"+strArr[0]+"' and '"+strArr[1]+"' ");
        		}else if(conditionValue == "is null"){
		        	arraySerarchList.push(" " + objArrayTwo[i+1].value+" "+tableName+arrayColsName[i].value+" "+objArrayOne[i+1].value+" ");
        		}else{
		        	arraySerarchList.push(" " + objArrayTwo[i+1].value+" "+tableName+arrayColsName[i].value+" "+objArrayOne[i+1].value+" '"+arrayColsValue[i].value+"' ");
        		}
        	}
        	
        	var whereAnd = "";
        	for(var i=0;i<arraySerarchList.length;i++){
        		whereAnd += arraySerarchList[i];
        	}
        	
        	_jsonObj.methodname = "queryPage";
			_jsonObj.logicdata = '[{\"where\":\"' + whereAnd + '\",\"types\":\"serch2\"}]';
			manager.loadData();
        	
        	arraySerarchList.length = 0;
        	win1.hide();
        	
		},closeWin);
	}else{
		win1.show();
	}
}

/*
 * 动态给table添加一个tr-高级查询
 */
function tallSearchCols(clValue){
	var bool = false;
	var arrayColsName = $("[name=colsName]");
	var conHtml = '<select name="luojiTwo"><option value="and">与</option></select>';
	
	for(var i=0; i<arrayColsName.length; i++){
		if(clValue == arrayColsName[i].value){
			bool = true;
			break;
		}
	}
	if(bool){
		conHtml = $("#conditionAnd").html();
	}
	
	var clName = $("option[value='" + clValue + "']").eq(0).text()
	if(clValue=="aa.tbe_birthday" || clValue=="aa.tbe_married_time" || clValue == 'aa.tbfi_spouse_birthday' ){
		$("#appendTable").append('<tr style="height:26px;"><td width="60px"><input name="colsName"  type="hidden" value="'+clValue+'">'+clName+'</td><td width="120px">'+$("#condition").html()+'</td><td width="180px"><input name="colsValue" class="times" type="text" onkeyup="this.value=formatdata(this.value);" ></td><td width="90px">'+conHtml+'</td><td width="60px" style="cursor: pointer;" onClick="getDel(this)">删除</td></tr>');
		$(".times").ligerDateEditor({width :150});
	}else if(clValue=="aa.tbe_sex" || clValue == 'aa.tbfi_spouse_sex'){
		$("#appendTable").append('<tr style="height:26px;"><td width="60px"><input name="colsName"  type="hidden" value="'+clValue+'">'+clName+'</td><td width="120px">'+$("#condition").html()+'</td><td width="180px"><select name="colsValue" type="text" style="width:150px"><option value="男">男</option><option value="女">女</option></select></td><td>'+conHtml+'</td><td style="cursor: pointer;" width="60px" onClick="getDel(this)">删除</td></tr>');
	} else if(clValue == 'aa.tbe_marital_status'){
		$("#appendTable").append('<tr style="height:26px;"><td width="60px"><input name="colsName"  type="hidden" value="'+clValue+'">'+clName+'</td><td width="120px">'+$("#condition").html()+'</td><td width="180px"><select name="colsValue" type="text" style="width:150px"><%=tbe_marital_status%></select></td><td>'+conHtml+'</td><td style="cursor: pointer;" width="60px" onClick="getDel(this)">删除</td></tr>');
	} else {
		$("#appendTable").append('<tr style="height:26px;"><td width="60px"><input name="colsName"  type="hidden" value="'+clValue+'">'+clName+'</td><td width="120px">'+$("#condition").html()+'</td><td width="180px"><input name="colsValue" type="text" style="width:150px"></td><td width="90px">'+conHtml+'</td><td width="60px" style="cursor: pointer;" onClick="getDel(this)">删除</td></tr>');
	}
}

/*
 * 删除条件-高级查询
 */
function getDel(ele){
	$(ele).parent().remove();  
}

function getBirthDay(ele){
	var val = getBirthDayFromID(ele.value);
	if(val != ''){
		$("#tbfi_spouse_birthday").val(val);
	}
}
</script>
	</head>
	<body>
		<table class="serTable">
			<tr>
				<td>
					机构：<select id="org2" name="org2" style="width: 164px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td>姓名：<input id="ser1" style="width: 160px;" /></td>
				<td><!-- 身份证：<input id="ser4" style="width: 160px;" /> -->
				是否新婚：<select id="ser4" style=" width: 164px;">
						<option value="2">全部</option>
						<option value="1">是</option>
						<option value="0">否</option>
					</select>
				</td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch1();" /></td>
			</tr>
			<tr>
				<td>
					婚姻状态：<select id="ser5" style="width: 164px;">
						<option value="0">全部</option>
						<%=tbe_marital_status%>
					</select>
				</td>
				<td>是否一汽：<select id="ser6" style=" width: 164px;">
						<option value="2">全部</option>
						<option value="1">是</option>
						<option value="0">否</option>
					</select>
				</td>
				<td>家庭子女数：<input id="ser7" style="width: 160px;" /></td>
				<td><input class="btn2" value="高级搜索" type="button" onclick="serch2();" /></td>
			</tr>
		</table>
		<div id="emp_grid"></div>
		<div id="emp_mari" style="display: none;">
			<form id="emp_mari_form" name="emp_mari_form">
				<input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="tbe_spouse_id" name="tbe_spouse_id" value="" />
				<input type="hidden" id="tbfi_spouse_is_join" name="tbfi_spouse_is_join" value="0" />
				<input type="hidden" id="tbe_marital_status_text" name="tbe_marital_status_text" value="" />
				<input type="hidden" id="tbe_age" name="tbe_age" value="" />
				<input type="hidden" id="tbe_birthday" name="tbe_birthday" value="" />
				<input type="hidden" id="tbe_status" name="tbe_status" value="" />
				<input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="org_name" name="org_name" value="" />
				<input type="hidden" id="tbe_position" name="tbe_position" value="" />
				<input type="hidden" id="tbfi_spouse_idcard_u" name="tbfi_spouse_idcard_u" value="" />
				<input type="hidden" id="tbfi_peo_num" name="tbfi_peo_num" value="1" />
				<input type="hidden" id="tbfi_spouse_age" name="tbfi_spouse_age" value="0" />
				<input type="hidden" id="tbfi_mobile" name="tbfi_mobile" value="" />
				<input type="hidden" id="tbfi_valid" name="tbfi_valid" value="0" />
				<input type="hidden" id="tbfi_phone" name="tbfi_phone" value="" />
				<input type="hidden" id="tbfi_address" name="tbfi_address" value="" />

				<table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>员工基本信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label" style="width: 100px;">员工姓名：</td>
						<td><input class="textbg1" id="tbe_name" name="tbe_name" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">员工性别：</td>
						<td><input class="textbg1" name="tbe_sex" id="tbe_sex" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">身份证号：</td>
						<td>
							<input class="textbg1" id="tbe_idcard" name="tbe_idcard" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/>
						</td>
						<td></td>
					</tr>
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>员工婚姻信息（必填）</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">婚姻状态：</td>
						<td>
							<select id="tbe_marital_status" name="tbe_marital_status" onchange="valiMarital(this);" style="width: 182px; margin-left: 1px;">
								<%=tbe_marital_status %>
							</select>
						</td>
						<td><font color="red">*</font></td>
						<td class="form_label">结婚时间：</td>
						<td><input id="tbe_married_time" name="tbe_married_time" onkeyup="this.value=formatdata(this.value);" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td><font color="red">*</font></td>
						<td class="form_label">结婚证号：</td>
						<td><input class="textbg1" id="tbe_marriage_certificate" name="tbe_marriage_certificate" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" /></td>
						<td></td>
					</tr>
					
					<tr>
						<td class="form_label">本季新结婚的：</td>
						<td align="left" id="emp_reserve5">
							<input style="margin-top: 2px; margin-left: 5px;" type="radio" name="emp_reserve5" value="1" />
							是
							<input style="margin-top: 2px; margin-left: 5px;" type="radio" name="emp_reserve5" value="0" checked="checked" />
							否
						</td>
						<td align="left" colspan="6">
							<font color="#fe4365" style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;新婚提示：本季度结婚的则将其选“是”，否则不选。（初婚和再婚都叫新婚）</font>
						</td>
					</tr>
					
					<tr>
						<td class="form_label">新结婚且晚婚：</td>
						<td align="left" id="tbe_is_late_marriage">
							<input style="margin-top: 2px; margin-left: 5px;" type="radio" name="tbe_is_late_marriage" value="1" checked="checked" />
							是
							<input style="margin-top: 2px; margin-left: 5px;" type="radio" name="tbe_is_late_marriage" value="0" />
							否
						</td>
						
						<td align="left" colspan="7">
							<font color="#fe4365" style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;晚婚提示：初婚时达到晚婚年龄则选“是”。（男方为25周岁，女方为23周岁）</font>
						</td>
						
					</tr>
					
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>配偶基本信息（必填）</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">一汽员工：</td>
						<td>
							<input id="checkbox1" name="checkbox1" type="checkbox" onclick="checkEmp(1);"/>
							是
							<input id="empBtn" name="empBtn" type="button" class="btn1" value="选择" onclick="openEmp(1);" disabled="disabled" />
						</td>
						<td colspan="7" align="left">
						    <font color="#fe4365" style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;温馨提示：如果配偶是一汽员工，选“是”并点“选择”；若不是则正常填写。</font>
						</td>
					</tr>
					<tr>
						<td class="form_label">配偶姓名：</td>
						<td>
							<input class="textbg1" id="tbfi_spouse_name" name="tbfi_spouse_name" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">配偶性别：</td>
						<td>
							<input class="textbg1" id="tbfi_spouse_sex" name="tbfi_spouse_sex"  readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td colspan="3"></td>
					</tr>
					<tr>
						<td class="form_label">出生日期：</td>
						<td>
							<input id="tbfi_spouse_birthday" name="tbfi_spouse_birthday" onkeyup="this.value=formatdata(this.value);" />
						</td>
						<td>
							<font color="red">*</font>
						</td>
						<td class="form_label">身份证号：</td>
						<td>
							<input class="textbg1" id="tbfi_spouse_idcard" name="tbfi_spouse_idcard" onblur="getBirthDay(this);"  onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">配偶单位：</td>
						<td>
							<input class="textbg1" id="tbfi_spouse_department" name="tbfi_spouse_department" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">配偶职务：</td>
						<td>
							<input class="textbg1" id="tbe_spell_code" name="tbe_spell_code" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'"	onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">文化程度：</td>
						<td>
							<input class="textbg1" id="tbe_qualification" name="tbe_qualification" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td></td>
						<td>
							<select id="tbfi_spouse_position" name="tbfi_spouse_position" style="width: 182px; display: none;">
								<option value=""></option>
								<option value="2">生产操作服务</option>
								<option value="1">专业技术管理</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>家庭基本信息（必填）</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">子女总数：</td>
						<td>
							<input class="textbg1" id="tbfi_children_num" name="tbfi_children_num" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">男孩数：</td>
						<td>
							<input class="textbg1" id="tbfi_children_mnum" name="tbfi_children_mnum" onkeyup="value=value.replace(/\D+/g,'');if(value.length > 2){value=value.substr(0,2);}" title="请输入数字!" onblur="sumChild();" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">女孩数：</td>
						<td>
							<input class="textbg1" id="tbfi_children_fnum" name="tbfi_children_fnum" onkeyup="value=value.replace(/\D+/g,'');if(value.length > 2){value=value.substr(0,2);}" title="请输入数字!" onblur="sumChild();" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">备注：</td>
						<td>
							<input class="textbg1" id="tbfi_memo" name="tbfi_memo" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td colspan="6" align="left">
						    <font color="#fe4365" style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;温馨提示：只填“男孩数”、“女孩数”，“子女总数”无需填写。</font>
						</td>
						
						
						
					</tr>
				</table>
			</form>
		</div>
		<div id="grid0-win" style="display: none;">
			<table class="serTable">
				<tr>
					<td>
						姓名：<input id="ser-name" style="width: 100px;" />
					</td>
					<td>
						身份证：<input id="ser-no" style="width: 150px;" />
					</td>
					<td><input class="btn2" value="搜索" type="button" onclick="serch3();" /></td>
				</tr>
			</table>
			<div id="grid0-div"></div>
		</div>

		<!-- 将用到的两个常用逻辑运算符初始化在页面中便于上面的使用  -->
		<div style="display: none;" id="condition">
			<select name="luojiOne">
				<option value="=">等于</option>
				<option value="<>">不等于</option>
				<option value=">">大于</option>
				<option value="<"">小于</option>
				<option value="is null">为NULL</option>
				<option value="like">包含</option>
				<option value="in">在...之中(1,2,3)</option>
				<option value="between">在...之间(1,2)</option>
			</select>
		</div>
		<div style="display: none;" id="conditionAnd">
			<select name="luojiTwo">
				<option value="and">与</option>
				<option value="or">或</option>
			</select>
		</div>
		<div id="tallSearch" style="display: none;">
			<table width="99%" height="100%">
				<tr>
					<td width="20%">
						字段列表
					</td>
					<td width="80%" style="text-algin: center;">
						<table width="100%">
							<tr>
								<td width="60px">字段名称</td>
								<td width="130px">条件匹配</td>
								<td width="150px">字段赋值</td>
								<td width="90px">条件关系</td>
								<td width="60px">移除操作</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<!-- select中给定的字段为数据库中字段，此处给出表明，是为了后台有多表查询时使用，但是此查询并不适合嵌套查询（子查询） 后台有统一替换过程  -->
					<td width="20%" style="vertical-align: top;">
						<select id="sel" style="height: 356px; width: 120px;" ondblclick="tallSearchCols(this.value);" multiple="multiple">
							<option value="aa.tbe_name">员工姓名</option>
							<option value="aa.tbe_sex">员工性别</option>
							<option value="aa.tbe_idcard">员工身份证号</option>
							<option value="aa.tbe_birthday">员工出生日期</option>
							<option value="aa.tbfi_spouse_name">配偶姓名</option>
							<option value="aa.tbfi_spouse_sex">配偶性别</option>
							<option value="aa.tbfi_spouse_birthday">配偶出生日期</option>
							<option value="aa.tbfi_spouse_idcard">配偶身份证号</option>
							<option value="aa.tbe_address">家庭住址</option>
							<option value="aa.tbe_family_phone">家庭电话</option>
							<option value="aa.tbe_marital_status">婚姻状态</option>
							<option value="aa.tbe_married_time">结婚时间</option>
							<option value="aa.tbe_marriage_certificate">结婚证号</option>
							<option value="aa.tbfi_children_num">家庭子女数</option>
							<option value="aa.tbfi_children_mnum">男孩数</option>
							<option value="aa.tbfi_children_fnum">女孩数</option>
						</select>
					</td>
					<td width="80%" style="text-algin: center;" valign="top">
						<table width="100%" id="appendTable">
						</table>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>
